package com.ifast.oupei.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ifast.oupei.dao.ItemsDao;
import com.ifast.oupei.dao.KeywordDao;
import com.ifast.oupei.domain.ItemsDO;
import com.ifast.oupei.domain.KeywordDO;
import com.ifast.oupei.service.ItemsService;
import com.ifast.common.base.CoreServiceImpl;

/**
 * 
 * <pre>
 * 
 * </pre>
 * <small> 2018-06-11 15:48:45 | Aron</small>
 */
@Service
public class ItemsServiceImpl extends CoreServiceImpl<ItemsDao, ItemsDO> implements ItemsService {
	@Autowired
	ItemsDao itemsDao;
	@Autowired
	KeywordDao keywordDao;
	/**
	 * 罗列所有的关键字
	 * @return
	 */
	@Override
	public List<ItemsDO> listAllItems(){
		List<ItemsDO> itemsList = itemsDao.selectAllItems();
		for (ItemsDO itemsDO : itemsList) {
			int id = itemsDO.getId();
			List<KeywordDO> keywordList = keywordDao.ListByItems(id);
			itemsDO.setKeywordList(keywordList);
		}
		return itemsList;
	}
	@Override
	public Integer selectOneByItemsName(String name) {
		return itemsDao.selectOneByItemsName(name);
	}
}
